package net.oschina.allchat.server.framework.core.internal;

import net.oschina.allchat.server.framework.core.IApplication;
import net.oschina.allchat.server.framework.core.config.IApplicationConfiguration;

import org.osgi.framework.BundleContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class ApplicationProxy {
	private static final Logger logger = LoggerFactory.getLogger(Activator.class);
	
	private IApplication application;
	
	public void start(BundleContext context, IApplicationConfiguration appConfiguration) {
		application = new Application(context, appConfiguration);
		
		try {
			application.start();
		} catch (Exception e) {
			logger.error("failed to start application", e);
		}
	}
	
	public void stop(BundleContext context) {
		try {
			application.stop();
		} catch (Exception e) {
			logger.error("failed to stop application", e);
		}
	}
}
